/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(http?s:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
 export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

export const PHONE_REG = (rules, value, callback) => {
  if (!value) {
    callback(new Error("请输入电话"));
  }
  if (!/^1[3456789]\d{9}$/.test(value)) {
    callback(new Error("号码格式有误"));
  }
  callback();
  console.log("phoneReg----->>>", rules, value);
};
